//
//  HomeNavigationItem.m
//  LoveFreshBeen
//
//  Created by 辛路琦 on 16/6/11.
//  Copyright © 2016年 xinluqi. All rights reserved.
//

#import "HomeNavigationItem.h"

@implementation HomeNavigationItem

// 如果子类重写了父类的特定构造方法, 那么必须使用super调用父类的特定构造方法

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) { // 如果不写这个, 就会出现警告
        
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor redColor] forState:UIControlStateSelected];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat imageWH = self.bounds.size.width *0.8;
    CGFloat imageX = (self.width - imageWH) *0.5;
    self.imageView.frame = CGRectMake(imageX, 0, imageWH, imageWH);
    self.titleLabel.frame = CGRectMake(0, self.bounds.size.height * 0.7, self.bounds.size.width, self.bounds.size.height * 0.3);
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
}

/**
 *  重写高亮方法, 不给任何内容, 到时候自定义button就不会有高亮状态
 */
- (void)setHighlighted:(BOOL)highlighted {}
@end
